﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once

#include "GcmpGeometryInterface.h"
#include "ICurve2d.h"
#include "GbmpConstants.h"

namespace gcmp
{
    /// \brief 二维椭圆
    ///
    class IEllipse2d : public ICurve2d
    {
        DEFINE_CAST_DERIVED(gcmp::IEllipse2d, gcmp::ICurve2d);
    public:
        /// \brief  根据圆心、长轴、长轴半径、短轴半径、起始弧度、终止弧度，逆时方向构造二维椭圆
        /// \param centerPoint       椭圆圆心
        /// \param majorAxis         椭圆长轴(单位化向量)
        /// \param majorRadius       长轴半径
        /// \param minorRadius       短轴半径
        /// \param startAngle        起始弧度(弧度,默认0.0)
        /// \param endAngle          终止弧度(弧度，默认gcmp::Constants::MATH_2PI)
        /// \param antiClockwise     顺逆方向，true：逆时， false：顺时
        /// \return  二维椭圆
        /// \see 当输入短轴半径大于长轴半径时，进行互换，保证短轴半径始终小于等于长轴半径
        GCMP_GEOMETRY_INTERFACE_EXPORT static OwnerPtr<IEllipse2d> Create(
            const Vector2d &centerPoint,
            const Vector2d &majorAxis,
            double majorRadius,
            double minorRadius,
            double startAngle = 0.0,
            double endAngle = Constants::MATH_2PI,
            bool antiClockwise = true);



    public:

        /// \brief  获取椭圆圆心
        /// \return 圆心
        virtual Vector2d GetCenter() const = 0;

        /// \brief  设置椭圆圆心
        /// \param centerPoint  圆心
        /// \return 成功返回true,否则返回false(默认返回True)
        virtual bool SetCenter(const Vector2d &centerPoint) = 0;

        /// \brief  获取椭圆长轴正方向
        /// \return 长轴正方向（单位向量）
        virtual Vector2d GetMajorAxis() const = 0;

        /// \brief  获取椭圆短轴正方向
        /// \return 短轴正方向（单位向量）
        virtual Vector2d GetMinorAxis() const = 0;

        /// \brief  获取椭圆长轴半径
        /// \return 长轴半径
        virtual double GetMajorRadius() const = 0;
        
        /// \brief  获取椭圆短轴半径
        /// \return 短轴半径
        virtual double GetMinorRadius() const = 0;

        /// \brief  获取起始角度
        /// \return  起始角度
        virtual double GetStartAngle() const = 0;

        /// \brief  获取终止角度
        /// \return  终止角度
        virtual double GetEndAngle() const = 0;

        /// \brief  根据圆心、长轴、长轴半径、短轴半径、起始弧度、终止弧度，逆时方向构造二维椭圆
        /// \param centerPoint       椭圆圆心
        /// \param majorAxis         椭圆长轴(单位化向量)
        /// \param majorRadius       长轴半径
        /// \param minorRadius       短轴半径
        /// \param startAngle        起始弧度(弧度, 默认0.0)
        /// \param endAngle          终止弧度(弧度，默认gcmp::Constants::MATH_2PI)
        /// \param antiClockwise     顺逆方向，true：逆时， false：顺时
        /// \return 成功返回true, 否则返回false(默认返回True)
        /// \see 当输入短轴半径大于长轴半径时，进行互换，保证短轴半径始终小于等于长轴半径
        virtual bool Set(const Vector2d &centerPoint, const Vector2d &majorAxis, double majorRadius,
            double minorRadius, double startAngle, double endAngle, bool antiClockwise = true) = 0;

        /// \brief  获取顺时针或逆时针方向，true：逆时， false：顺时
        /// \return  时针方向
        virtual bool IsAntiClockwise() const = 0;
        
    public:
        virtual ~IEllipse2d() {}
    };
}
